/**
 * 
 */
package com.witframework.baseapp.common.enterprise;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.javalid.annotations.core.ValidateDefinition;
import org.javalid.annotations.validation.NotEmpty;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;

import com.witframework.core.annotations.Wit;

/**
 * The Organization Tab is used to deﬁne an Organization. Each Organization has a Key
 * and Name and optionally a Description. When adding a new organization, you must re-login
 * to be able to access the new organization.
 * Please note that you will not be able to create new entities in this window if you have not
 * default set for all mandatory values!
 * @author wuxinyang
 * Jun 5, 2009 11:32:04 AM
 * 
 */

@Entity @Table(name="AD_ORG") @Wit(cnname="组织",description="机构,组织",cnproperty="name")
@ValidateDefinition
public class Organization{		
	private String id ;	
	@Wit(cnname="名称",description="组织名称")
	private String orgname;		
	@Wit(cnname="编码",description="组织编码")
	private String ad_org_id;
	@Wit(cnname="备注",description="说明")
	private String description;
	@Wit(cnname="是否总公司")
	private String issummary="N";		
	private String isready="Y";	
	private OrganizationInformation organizationInformation;	
	private OrganizationType organizationType;
	
	@Column(length=32)@Id
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}	
	
	@Column(length=60,nullable=false) @Length(max=60) @NotEmpty
	public String getOrgname() {
		return orgname;
	}
	public void setOrgname(String orgname) {
		this.orgname = orgname;
	}
	@Column(length=32)
	public String getAd_org_id() {
		return ad_org_id;
	}
	public void setAd_org_id(String ad_org_id) {
		this.ad_org_id = ad_org_id;
	}	
	@Column(length=255) @Length(max=255)
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(length=1,nullable=false) @Length(max=1)
	public String getIssummary() {
		if(issummary==null)
			return "N";
		return issummary;
	}
	public void setIssummary(String issummary) {
		this.issummary = issummary;
	}
	
	@Column(length=1,nullable=false)
	public String getIsready() {
		if(isready==null)
			return "Y";
		return isready;
	}
	public void setIsready(String isready) {
		this.isready = isready;
	}
	@OneToOne(optional = true, cascade = CascadeType.ALL, mappedBy = "organization")  
	public OrganizationInformation getOrganizationInformation() {
		return organizationInformation;
	}
	public void setOrganizationInformation(OrganizationInformation organizationInformation) {
		this.organizationInformation = organizationInformation;
	}
	@ManyToOne @LazyToOne(LazyToOneOption.FALSE)	
	public OrganizationType getOrganizationType() {
		return organizationType;
	}
	public void setOrganizationType(OrganizationType organizationType) {
		this.organizationType = organizationType;
	}
	
	
}
